/**
 * 
 */
package br.ufpr.inf.jobtuner.pso.mod;

/**
 * @author Evaristo
 * 
 * Class that implements the objective function to PSO Algorithm
 * 
 */
public class PSOFitness {

	/**
	 * Calculate the objective function
	 * @param p
	 * @return the result of objective function
	 */
	public static final double calculate(PSOParticle p) {
		/* Objective function */		
		double fitness = 0.0;
		
		for(double posPoint : p.getPosition()){
			fitness += Math.pow(posPoint, 2);
		}
		return Math.sin(fitness);

		//Different test
//		for(double posPoint : p.getPosition()){
//			fitness += Math.pow(posPoint, 2);
//		}
//		return -1 * fitness;
	}
	
}
